import getState from "@/api/state";
import HorizontalBarChart from "@/template/HorizontalBarChart/HorizontalBarChart";
import React from "react";
import { useEffect } from "react";
import { useState } from "react";

const InsModule1 = ({ condition }) => {
    const [message, setMessage] = useState("暂无数据");
    const [loading, setLoading] = useState(true);
    const [state, setState] = useState({
        data: []
    })


    useEffect(() => {
        getState({
            moduleName: "cnt",
            state,
            apiUrl: "/cifgp-core-api/insQuery/monthAndYear",
            condition: { ...condition, cType: "insNum" },
            setState,
            setLoading,
            setMessage,
        })
    }, [condition])


    return (
        <>
            <HorizontalBarChart
                message={message}
                loading={loading}
                style={{ width: "25%" }}
                sort={"up"}
                heightAuto
                hideBtn
                title="各险种投保分布"
                unit={"保单量"}
                data={[
                    state
                ]}
                fieldNames={{
                    name:"保单量",
                    value:"个"
                }}
            />
        </>
    )
}
export default InsModule1;